<%inherit file="/front/base/userbase.html"/>
<%def name="center()">
<style>
    table tr td
    {
        font-size:12px;
    }
    table tr td p
    {
        margin: 0px;
    }
</style>
    <div class="row">
        <h3 class="lit page-header no-margin" style="margin-bottom:10px;">我的优惠券</h3>
        <table class="table table-bordered table-striped" style="table-layout:fixed;">
            <thead class="typ">
                <tr>
                    <th width="20" style="text-align:center">优惠券</th>
                    <th width="35" style="text-align:center">标题及券号</th>
                    <th width="90" style="text-align:center">详细</th>
                    <th width="10" style="text-align:center">状态</th>
                </tr>
            </thead>
            <tbody>
                %for couponrandom in couponrandoms.object_list: 
                <tr>
                    <td>
                        <p><img src="${couponrandom.coupon.picture}"/></p>
                    </td>
                    <td style="text-align:center;">
                        <p><a href="/coupons/detail/${couponrandom.coupon.id}.html" target="_blank">${couponrandom.coupon.name}</a></p>
                        <br/>
                        %if not couponrandom.coupon.coupontype in (1,2):
                        <p><code>券号</code>&nbsp;${couponrandom.randomserial}</p>
                        %endif
                        <p><code>商家</code>&nbsp;${couponrandom.coupon.businessuser.companyname}</p>
                        <p><code>过期时间</code>&nbsp;${couponrandom.coupon.leftdays}天</p>
                    </td>
                    <td style="text-align:left;">
                        ${couponrandom.coupon.shortdetail|n}
                    <td style="text-align:center;">
                        <p>${couponrandom.statustext}</p>
                    </td>
                </tr>
                %endfor
                <tr>
                    <td colspan="4">
                        <div class="pagination pull-right">
                            <ul>
                                %if couponrandoms.hasprevious:
                                <li><a href="${couponrandoms.get_page_url(request.url, couponrandoms.previous)}">上一页</a></li>
                                %else:
                                <li class="active"><a>上一页</a></li>
                                %endif

                                %if couponrandoms.current_index > 3:
                                <li><a href="${couponrandoms.get_page_url(request.url, 1)}">1</a></li>
                                <li><a>...</a></li>
                                %endif

                                %for i in range(-2, min(couponrandoms.pagecount - couponrandoms.current_index + 1,3)):
                                %if couponrandoms.current_index+i > 0:
                                %if i==0:
                                <li class="active"><a>${couponrandoms.current_index + i}</a></li>
                                %else:
                                <li><a href="${couponrandoms.get_page_url(request.url, couponrandoms.current_index+i)}">${couponrandoms.current_index + i}</a></li>
                                %endif
                                %endif
                                %endfor

                                %if couponrandoms.pagecount - couponrandoms.current_index > 2:
                                <li><a href="#">...</a></li>
                                <li><a href="#">${couponrandoms.pagecount}</a></li>
                                %endif

                                %if couponrandoms.hasnext:
                                <li><a href="${couponrandoms.get_page_url(request.url, couponrandoms.next)}">下一页</a></li>
                                %else:
                                <li class="active"><a>下一页</a></li>
                                %endif
                            </ul>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>

</%def>
